package org.gitman.agent.gui;

import java.awt.BorderLayout;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.gitman.agent.platform.PlatformManager;

public class SummaryPanel extends JPanel {

	private PlatformManager platformManager;
	private static String [] allNames = {
		"Iterations:", "-",	
		"Vertices:", "-",
		"Steps:", "-", 
		"Edgeds:", "-",
		"Time:", "-", 
		"Success:", "-",
		"Agents:", "-", 
		"Failure:", "-"
	};
	
	private static String [] stepMetricNames = {
		"All Steps:", "-", 
		"All iterations:", "-",
		"Max(Step/Agent):", "-", 
		"Min(Step/Agent):", "-",
		"Avg(Step/Agent):", "-", 
		"(Max - Min):", "-",
		"Max(Iter/Min Path):", "-", 
		"Min(Iter/Min Path):", "-",
		"Avg(Iter/Min Path):", "-"	
	};
	
	private static String [] timeMetricNames = {
		"Total time:", "-",
		"Time/Step:", "-",
		"Time/Iteration:", "-"
	};
	
	public SummaryPanel(PlatformManager platformManager) {
		this.platformManager = platformManager;
		
		setLayout(new BorderLayout());
		
		JPanel overAll = new JPanel(new GridLayout(8, 2));
		add(overAll, BorderLayout.NORTH);
		overAll.setBorder(BorderFactory.createTitledBorder("Overall Summary"));
		JLabel [] allLab = new JLabel[allNames.length];
		for(int i =0;i<allNames.length; i++ ){
			allLab[i] = new JLabel(allNames[i]);
			overAll.add(allLab[i]);
		}
			
		
		JPanel p1 = new JPanel(new BorderLayout());
		add(p1, BorderLayout.CENTER);
		
		JPanel stepMetricPanel = new JPanel(new GridLayout(9, 2));
		p1.add(stepMetricPanel, BorderLayout.NORTH);
		stepMetricPanel.setBorder(BorderFactory.createTitledBorder("Metric 1: Steps"));
		JLabel [] stepLab = new JLabel[stepMetricNames.length];
		for(int i =0;i<stepMetricNames.length;i++){
			stepLab[i] = new JLabel(stepMetricNames[i]);
			stepMetricPanel.add(stepLab[i]);
		}
		
		JPanel p2 = new JPanel(new BorderLayout());
		p1.add(p2, BorderLayout.CENTER);
		
		JPanel timeMetricPanel = new JPanel(new GridLayout(3,2));
		p2.add(timeMetricPanel, BorderLayout.NORTH);
		timeMetricPanel.setBorder(BorderFactory.createTitledBorder("Metric 2: Time"));
		JLabel [] timeLab = new JLabel[timeMetricNames.length];
		for(int i =0;i<timeMetricNames.length;i++){
			timeLab[i] = new JLabel(timeMetricNames[i]);
			timeMetricPanel.add(timeLab[i]);
		}
		
		JPanel options = new JPanel(new BorderLayout());
		JButton expport = new JButton("Export to CSV file");
		options.add(expport,BorderLayout.EAST);
		add(options, BorderLayout.SOUTH);
		
	}
	
}
